package com.example.demo.model;

import com.example.demo.enums.ResultCodeEnum;
import com.fasterxml.jackson.databind.util.ObjectBuffer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@Data
@NoArgsConstructor
public class Result<T> {
   private ResultCodeEnum code;
   private String errMsg;
   private T data;
    public static <T>Result<T> nologin(){
        //用户未登录
        Result result = new Result<>();
        result.setCode(ResultCodeEnum.NOLOGIN);
        result.setErrMsg("用户未登录!");
        return result;
    }
    public static <T> Result<T> success(T data){
        Result result = new Result<>();
        result.setCode(ResultCodeEnum.SUCCESS);
        result.setData(data);

        return result;
    }
    public static <T> Result<T> fail(String errMag){
     Result result =new Result<>();
     result.setCode(ResultCodeEnum.FAIL);
     result.setErrMsg(errMag);
     result.setData(null);
     return result;
    }


}
